import React, { Component, PropTypes } from 'react';
import classNames from 'classnames';
import s from './maskspin.less';
import Loading from './loading.gif';

class MaskSpin extends Component {
  render() {
    const eleClass = classNames({
      [s.spin]: true,
      [s.hide]: !!!this.props.show,
      [s.fixed]: this.props.fixed,
    });
    const icon = this.props.icon === undefined ? <img src={Loading} /> : this.props.icon;
    return (
      <div className={eleClass}>
        <div className={s.mask}></div>
        {icon}
      </div>
    );
  }
}

MaskSpin.propTypes = {
  show: PropTypes.bool,
  fixed: PropTypes.bool,
  icon: PropTypes.node,
};

export default MaskSpin;
